﻿using Present.Commands.Async.Actions;
using Present.Commands.Async.Actions.Decorators;

namespace Present.Commands.Fluent
{
    public abstract class ActionBuilder<TParameter, TResult>
    {
        

        public ActionBuilder<TParameter, TResult> ShowBusy(IBusyable busyable)
        {
            return new SimpleActionBuilder<TParameter, TResult>(() => new BusyAsyncActionDecorator<TParameter, TResult>(GetAction(), busyable));
        }

        public ActionBuilder<TParameter, TResult> CancelOnNewExecution()
        {
            return new SimpleActionBuilder<TParameter, TResult>(() => new CancelOnNewExecutionAsyncActionDecorator<TParameter, TResult>(GetAction()));
        }


        protected abstract IAsyncAction<TParameter, TResult> GetAction();

       

        public IAsyncAction<TParameter, TResult> ToAction()
        {
            return GetAction();
        }

    }
}